using System;
using System.Windows.Input;
using CommunityToolkit.Mvvm.Input;

namespace CANBusTools.ViewModels
{
    public class SteerControlViewModel : ViewModelBase
    {
        private readonly object _busHelper;

        private string _steerAngle = string.Empty;
        public string SteerAngle
        {
            get => _steerAngle;
            set
            {
                if (_steerAngle != value)
                {
                    _steerAngle = value;
                    OnPropertyChanged(nameof(SteerAngle));
                }
            }
        }

        public ICommand SetSteerCommand { get; }

        public SteerControlViewModel(object busHelper)
        {
            _busHelper = busHelper;
            SetSteerCommand = new RelayCommand(SetSteer);
        }

        private void SetSteer()
        {
            if (double.TryParse(SteerAngle, out double angle))
            {
                // TODO: 替换为实际调用 _busHelper.SteerAngleSwitch(angle);
                Console.WriteLine($"Set steer angle to {angle}");
            }
            else
            {
                Console.WriteLine("Invalid steer angle input");
            }
        }
    }
}
